<?php

namespace common\models\Ad;

use Yii;

/**
 * This is the model class for table "ad".
 *
 * @property integer $ad_id
 * @property integer $position_id
 * @property integer $media_type
 * @property string $ad_name
 * @property string $ad_link
 * @property string $ad_code
 * @property string $start_time
 * @property string $end_time
 * @property string $link_man
 * @property string $link_email
 * @property string $link_phone
 * @property string $click_count
 * @property integer $enabled
 */
class Ad extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'ad';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['position_id'], 'integer'],
            [['ad_code'], 'required'],
            [['ad_code'], 'string'],
            [['start_time', 'end_time'], 'safe'],
            [['ad_name','media_type','link_man', 'link_email', 'link_phone'], 'string', 'max' => 60],
            [['ad_link'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ad_id' => Yii::t('app', '广告列表'),
            'media_type' => Yii::t('app', '媒介类型'),
            'ad_name' => Yii::t('app', '广告名称'),
            'ad_link' => Yii::t('app', '广告链接'),
            'ad_code' => Yii::t('app', '缩略图'),
            'position_id' => Yii::t('app', '广告位名称'),
            'start_time' => Yii::t('app', '开始时间'),
            'end_time' => Yii::t('app', '结束时间'),
            'link_man' => Yii::t('app', 'Link Man'),
            'link_email' => Yii::t('app', 'Link Email'),
            'link_phone' => Yii::t('app', 'Link Phone'),
//            'click_count' => Yii::t('app', '点击次数'),
//            'enabled' => Yii::t('app', '生成订单'),
        ];
    }
	public static function getAdposition($id){
		return AdPosition::findOne($id)->position_name;
	}
}
